package com.smartcampusbackend.service.impl;

import com.smartcampusbackend.config.SparkConfig;
import com.smartcampusbackend.service.SparkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SparkServiceImpl implements SparkService {

    @Autowired
    private SparkConfig config;

    @Override
    public String ask(String question){
        String result = SparkWebSocketClient.sendAndReceive(
                config.getHostUrl(),
                config.getAppid(),
                config.getApiKey(),
                config.getApiSecret(),
                question
        );
        System.out.println("最终返回给前端的AI内容: " + result); // 新增日志
        return result;
    }
}
